from loguru import logger
import time

def grade_ranking():
    students = []
    num = int(input("请输入学生总数： "))
    print("请依次输入每个学生的各项信息(学号,姓名,分数中间用空格隔开)")
    print("学号 姓名 分数")
    for x in range(num):
        id,name,score = input().split()
        id = int(id)
        name = str(name)
        score = float(score)
        if score <= 120 and score >=0:
            students.append((id,name,score))
        else:
            print("请输入0至120以内的有效分数!")
            exit()
    ranked_students = sorted(students,key = lambda x : (-x[2],x[0]))
    print("====成绩排名====")
    print(f"{'排名'}\t{'学号'}\t{'姓名'}\t  {'分数'}\t")
    for i, (id, name, score) in enumerate(ranked_students, 1):
        print(f"{i}\t{id}\t{name}\t  {score}\t")

if __name__ == "__main__":
    logger.info("Python_grade_ranking-v1.0")
    time.sleep(1.5)
    logger.info("正在加载成绩排名函数...")
    time.sleep(1.5)
    grade_ranking()
    time.sleep(2)
    logger.info("程序运行完毕,请复制成绩排名数据.")
    exit()